<%--
  Created by IntelliJ IDEA.
  User: koizumisinya
  Date: 2017/12/05
  Time: 0:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    Cookie cookie = new Cookie("cookieA", "abc");
    response.addCookie(cookie);
    Cookie cookie2 = new Cookie("cookieB", "aaa");
    cookie2.setMaxAge(60);//设置cookie保存时长 60秒 (<0不保存； 0删除； >0 保存)
    response.addCookie(cookie2);
%>

<h1>获取Cookie</h1>
<%
    Cookie[] cookies = request.getCookies();
    if (cookie != null) {
        for (Cookie temp : cookies) {
            out.print(temp.getName() + " : " + temp.getValue() + "<br/>");
        }
    }
%>
</body>
</html>
